
package pushy.client;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException; 
import java.util.HashMap; 
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;



/**
 *
 * @author dmeyer5
 */

public class Darstellung {
    private HashMap<String, BufferedImage> filePathes;
    
    public Darstellung() {
        filePathes = new HashMap<String, BufferedImage>();
        try {
            liesBildDateien();
        } catch (IOException ex) {
            Logger.getLogger(Darstellung.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public BufferedImage anzeigen(int id) {
        //System.out.println("Versuche anzuzeigen: " + id + " " + filePathes.containsKey(id + ".png"));
        if(filePathes.containsKey(id + ".png")) return filePathes.get(id + ".png");
        System.err.println(id + ".png nicht gefunden");
        return null;
    }
    
    private HashMap<String, BufferedImage> liesBildDateien() throws IOException {
        File inputFile = new File("src/Grafiken/Level");
        File[] dateienFileArray = inputFile.listFiles();
        for (File dateienFileArray1 : dateienFileArray) {
            if (dateienFileArray1.isFile()) {
                filePathes.put(dateienFileArray1.getName(), ImageIO.read(dateienFileArray1));
            }
        }
        
        return filePathes;
    } 
}
